<!DOCTYPE HTML>
<html lang="zh-hans" >
    <!-- Start book Python基础 -->
<!-- Start book Python基础 -->
    <head>
        <!-- head:start -->
<!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>变量及数据类型 | Python基础</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        <meta name="author" content="姜伟">
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-prism/prism.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="chapter10.html" />
    
    
    <link rel="prev" href="chapter08.html" />
    

        <!-- head:end -->
<!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
<!-- body:start -->
        
    <div class="book"
        data-level="9"
        data-chapter-title="变量及数据类型"
        data-filepath="chapter09.md"
        data-basepath="."
        data-revision="Mon Feb 03 2020 11:09:50 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="index.html">
                
                        <i class="fa fa-check"></i>
                        
                        学习目标
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="chapter01.html">
            
                
                    <a href="chapter01.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        计算机组成
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="chapter02.html">
            
                
                    <a href="chapter02.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        什么是编程语言
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3" data-path="chapter03.html">
            
                
                    <a href="chapter03.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Python语言介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4" data-path="chapter04.html">
            
                
                    <a href="chapter04.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        安装配置Python
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5" data-path="chapter05.html">
            
                
                    <a href="chapter05.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        开发工具介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6" data-path="chapter06.html">
            
                
                    <a href="chapter06.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        Pycharm的基本使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7" data-path="chapter07.html">
            
                
                    <a href="chapter07.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        交互式编程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8" data-path="chapter08.html">
            
                
                    <a href="chapter08.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        注释的使用
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="9" data-path="chapter09.html">
            
                
                    <a href="./chapter09.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        变量及数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10" data-path="chapter10.html">
            
                
                    <a href="chapter10.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                        标识符和关键字
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="11" data-path="chapter11.html">
            
                
                    <a href="chapter11.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>11.</b>
                        
                        输出语句
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12" data-path="chapter12.html">
            
                
                    <a href="chapter12.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.</b>
                        
                        输入语句
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本书使用 GitBook 发布
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="" >Python基础</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x53D8;&#x91CF;&#x4EE5;&#x53CA;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x53D8;&#x91CF;&#x4EE5;&#x53CA;&#x6570;&#x636E;&#x7C7B;&#x578B;</h1>
<h2 id="&#x4E00;&#x3001;&#x53D8;&#x91CF;&#x7684;&#x5B9A;&#x4E49;">&#x4E00;&#x3001;&#x53D8;&#x91CF;&#x7684;&#x5B9A;&#x4E49;</h2>
<p>&#x5BF9;&#x4E8E;&#x91CD;&#x590D;&#x4F7F;&#x7528;&#xFF0C;&#x5E76;&#x4E14;&#x7ECF;&#x5E38;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x4E3A;&#x53D8;&#x91CF;&#xFF0C;&#x6765;&#x63D0;&#x9AD8;&#x7F16;&#x7A0B;&#x6548;&#x7387;&#x3002;</p>
<p>&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#x7684;&#x8BED;&#x6CD5;&#x4E3A;: <code>&#x53D8;&#x91CF;&#x540D; = &#x53D8;&#x91CF;&#x503C;</code>&#x3002;(&#x8FD9;&#x91CC;&#x7684; = &#x4F5C;&#x7528;&#x662F;&#x8D4B;&#x503C;&#x3002;)</p>
<p>&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#x540E;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x540D;&#x6765;&#x8BBF;&#x95EE;&#x53D8;&#x91CF;&#x503C;&#x3002;</p>
<p>&#x5982;&#x4E0B;&#x793A;&#x4F8B;:</p>
<pre><code class="lang-python"><span class="hljs-comment"># &#x4E0D;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x6253;&#x5370;&#x4E09;&#x6B21; &quot;&#x4ECA;&#x5929;&#x5929;&#x6C14;&#x771F;&#x597D;&quot;,&#x5982;&#x679C;&#x9700;&#x8981;&#x53D8;&#x6210;&#x6253;&#x5370; &quot;&#x4ECA;&#x5929;&#x5929;&#x6C14;&#x4E0D;&#x597D;&quot; &#x9700;&#x8981;&#x4FEE;&#x6539;&#x4E09;&#x884C;&#x4EE3;&#x7801;</span>
print(<span class="hljs-string">&quot;&#x4ECA;&#x5929;&#x5929;&#x6C14;&#x771F;&#x597D;&quot;</span>)
print(<span class="hljs-string">&quot;&#x4ECA;&#x5929;&#x5929;&#x6C14;&#x771F;&#x597D;&quot;</span>)
print(<span class="hljs-string">&quot;&#x4ECA;&#x5929;&#x5929;&#x6C14;&#x771F;&#x597D;&quot;</span>)


<span class="hljs-comment"># &#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x8868;&#x793A;&#x8FD9;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x5982;&#x679C;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x5185;&#x5BB9;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x53D8;&#x91CF;&#x5BF9;&#x5E94;&#x7684;&#x503C;&#x5373;&#x53EF;</span>
weather = <span class="hljs-string">&quot;&#x4ECA;&#x5929;&#x5929;&#x6C14;&#x771F;&#x597D;&quot;</span>
print(weather)  <span class="hljs-comment"># &#x6CE8;&#x610F;&#xFF0C;&#x53D8;&#x91CF;&#x540D;&#x4E0D;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x5F15;&#x53F7;&#x5305;&#x88F9;</span>
print(weather)
print(weather)
</code></pre>
<ul>
<li>&#x8BF4;&#x660E;:<ul>
<li>&#x6240;&#x8C13;&#x53D8;&#x91CF;&#x540D;&#xFF0C;&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x7BB1;&#x5B50;&#xFF0C;&#x5F53;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x503C;&#xFF0C;&#x5C31;&#x628A;&#x5BF9;&#x5E94;&#x7684;&#x7BB1;&#x5B50;&#x62FF;&#x6765;&#x3002;</li>
<li>&#x53D8;&#x91CF;&#x5373;&#x662F;&#x53EF;&#x4EE5;&#x53D8;&#x5316;&#x7684;&#x91CF;&#xFF0C;&#x53EF;&#x4EE5;&#x968F;&#x65F6;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x3002;</li>
<li>&#x7A0B;&#x5E8F;&#x5C31;&#x662F;&#x7528;&#x6765;&#x5904;&#x7406;&#x6570;&#x636E;&#x7684;&#xFF0C;&#x800C;&#x53D8;&#x91CF;&#x5C31;&#x662F;&#x7528;&#x6765;&#x5B58;&#x50A8;&#x6570;&#x636E;&#x7684;&#x3002;</li>
</ul>
</li>
</ul>
<h2 id="&#x4E8C;&#x3001;&#x53D8;&#x91CF;&#x7684;&#x7C7B;&#x578B;">&#x4E8C;&#x3001;&#x53D8;&#x91CF;&#x7684;&#x7C7B;&#x578B;</h2>
<p>&#x7A0B;&#x5E8F;&#x4E2D;: &#x5728; <strong>Python &#x91CC;&#x4E3A;&#x4E86;&#x5E94;&#x5BF9;&#x4E0D;&#x540C;&#x7684;&#x4E1A;&#x52A1;&#x9700;&#x6C42;&#xFF0C;&#x4E5F;&#x628A;&#x6570;&#x636E;&#x5206;&#x4E3A;&#x4E0D;&#x540C;&#x7684;&#x7C7B;&#x578B;&#x3002;</strong>
&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="imgs/&#x6570;&#x636E;&#x7C7B;&#x578B;.png" alt=""></p>
<h2 id="&#x4E09;&#x3001;&#x67E5;&#x770B;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x4E09;&#x3001;&#x67E5;&#x770B;&#x6570;&#x636E;&#x7C7B;&#x578B;</h2>
<ul>
<li>&#x5728;python&#x4E2D;&#xFF0C;&#x53EA;&#x8981;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#xFF0C;&#x800C;&#x4E14;&#x5B83;&#x6709;&#x6570;&#x636E;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x7684;&#x7C7B;&#x578B;&#x5C31;&#x5DF2;&#x7ECF;&#x786E;&#x5B9A;&#x4E86;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x54B1;&#x4EEC;&#x5F00;&#x53D1;&#x8005;&#x4E3B;&#x52A8;&#x7684;&#x53BB;&#x8BF4;&#x660E;&#x5B83;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x7CFB;&#x7EDF;&#x4F1A;&#x81EA;&#x52A8;&#x8FA8;&#x522B;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5728;&#x4F7F;&#x7528;&#x7684;&#x65F6;&#x5019; <strong>&quot;&#x53D8;&#x91CF;&#x6CA1;&#x6709;&#x7C7B;&#x578B;&#xFF0C;&#x6570;&#x636E;&#x624D;&#x6709;&#x7C7B;&#x578B;&quot;</strong>&#x3002;</li>
<li>&#x6BD4;&#x5982;&#x4E0B;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x6CA1;&#x6CD5;&#x9884;&#x6D4B;&#x53D8;&#x91CF; b &#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x4F46;&#x662F; a &#x7684;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x6570;&#x636E;&#x6765;&#x786E;&#x8BA4;&#x3002;</li>
</ul>
<p><img src="imgs/&#x6570;&#x636E;&#x624D;&#x6709;&#x7C7B;&#x578B;.png" alt=""></p>
<ul>
<li>&#x5982;&#x679C;&#x4E34;&#x65F6;&#x60F3;&#x8981;&#x67E5;&#x770B;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x5B58;&#x50A8;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <strong>type(&#x53D8;&#x91CF;&#x7684;&#x540D;&#x5B57;)</strong>&#xFF0C;&#x6765;&#x67E5;&#x770B;&#x53D8;&#x91CF;&#x5B58;&#x50A8;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;</li>
</ul>
<p><img src="imgs/&#x4F7F;&#x7528;type&#x67E5;&#x770B;&#x6570;&#x636E;&#x7C7B;&#x578B;.png" alt=""></p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="chapter08.html" class="navigation navigation-prev " aria-label="Previous page: 注释的使用"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="chapter10.html" class="navigation navigation-next " aria-label="Next page: 标识符和关键字"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-copy-code-button/toggle.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"prism":{},"splitter":{},"copy-code-button":{},"toggle-chapters":{},"highlight":{},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
<!-- body:end -->
    </body>
    <!-- End of book Python基础 -->
<!-- End of book Python基础 -->
</html>
